home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / HardwareProjects / IBM_Keyboard.lha / keydoc < prev   
Text File  |  1992-03-25  |  12KB  |  339 lines

  1. *****************************************************************************
  2. *                                        *
  3. *    All files included in disk Jocose Haven vol 1. Check directory IBMK!   *
  4. *                                        *
  5. *****************************************************************************
  6.  
  7.  
  8. IBM Keyboard Interfact Project, by ERic Rudolph, 1991.
  9. No Copyright Whatsoever, but I would like credit where it's due.
  10.  
  11. This is documentation for the circuit I built which converts the information
  12. put out by an XT or AT keyboard to that which can be recognized by an Amiga.
  13.  
  14. The circuit itself is a simple 8051 with an address latch and an Eprom.
  15. It is inserted between the keyboard and the Amiga and sends data in both
  16. directions to the Keyboard and the Amiga. 
  17.  
  18. Parts count could be reduced by using an 8751 which contains a 4k internal
  19. Eprom. Seeing as how I don't know how to program them yet, I will stick to
  20. the above design, but I am sure it's not hard to do. :-\
  21.  
  22. Full Parts List:
  23. ================
  24. 1) Intel 8031/8051, preferrably low power
  25. 2) 74373 address latch
  26. 3) 2732 Eprom
  27. 4) 11.059 MHZ crystal
  28. 5) 2 30pf caps
  29. 6) 1 10k resistor, 1/4 watt
  30. 7) 1 10uF electolytic cap
  31. 8) 2 momentary pushbutton switches. Neither is really needed.
  32. 10) connectors to the Amiga and the IBM
  33.  
  34. The total cost for these parts come to about $18.00 minus box and breadboard.
  35. It certainly would be cheaper to use some used components. 
  36.  
  37. Wiring List:
  38. ============
  39. INTEL 8031/8051:
  40. Port1, pins 1-8 can be connected in any manner whatsoever,
  41. so long as you change the source code. You can relocate
  42. the lines to the Keyboard and the Amiga wherever suitable.
  43. If you understand the 8051 or read the 8051 manual, it will make more
  44. sense.
  45.     pin    to
  46.     ===    ==
  47.     1(p1.0)    Keyboard Clock. Female 5-pin, pin #1
  48.     2    Keyboard Data, Female 5-pin, pin #2
  49.     3     
  50.     4    Amiga Clock
  51.     5    Amiga Data
  52.     6    Amiga Reset
  53.     7
  54.     8(p1.7)    XT/AT pin. Tie low to always convert an XT keyboard.
  55.         For Auto detect, leave pin unconnected.
  56.     9(reset) to - side of 10uF cap & 10k resistor & pushbutton switch
  57.         only if you want a manual CIRCUIT reset switch.
  58.     10(p3.0)
  59.     11
  60.     12(int0)  pushbutton switch2
  61.     13-16
  62.     17(p3.7)
  63.     18    clock crystal & 30pf cap1
  64.     19    clock crystal(other pin) & 30pf cap2
  65.     20     Ground
  66.     21(a8)    Eprom Addr8, 2732 pin#23
  67.     22     Eprom Addr9, 2732 pin#22
  68.     23     Eprom Addr10, 2732 pin#19
  69.     24(a11)    Eprom Addr11, 2732 pin#21
  70.     25-28
  71.     29    Eprom Read, 2732 pin#20
  72.     30    373 Gate, pin# 11
  73.     31     Ground
  74.     32(ad7)    373 D7, pin#13 & Eprom Data7, pin#17
  75.     33    373 D6, pin#14 & Eprom Data6, pin#16
  76.     34    373 D5, pin#8 & Eprom Data5, pin#15
  77.     35    373 D4, pin#7 & Eprom Data4, pin#14
  78.     36    373 D3, pin#4 & Eprom Data3, pin#13
  79.     37    373 D2, pin#3 & Eprom Data2, pin#11
  80.     38    373 D1, pin#17 & Eprom Data1, pin#10
  81.     39(ad0)    373 D0, pin#18 & Eprom Data0, pin#9
  82.     40    +5 Volts
  83. 74373:
  84.     1    Ground
  85.     2    Eprom Addr2, pin#6
  86.     3    done
  87.     4    done
  88.     5    Eprom Addr3, pin#5
  89.     6    Eprom Addr4, pin#4    
  90.     7    done
  91.     8    done
  92.     9    Eprom Addr5, pin#3    
  93.     10    Ground
  94.     11    done
  95.     12    Eprom Addr7, pin#1
  96.     13    done
  97.     14    done
  98.     15    Eprom Addr6, pin#2
  99.     16    Eprom Addr1, pin#7
  100.     17    done
  101.     18    done
  102.     19    Eprom Addr0, pin#8
  103.     20    +5 volts
  104. 2732 Prom:
  105.     1-11    done
  106.     12    Ground
  107.     13-17    done
  108.     18    Ground (chip enable. Doesn't save power very much)
  109.     19-23    done
  110.     24    +5 volts
  111. crystal:
  112.     connected between 8051 pins 18 and 19
  113. 30pf cap1:
  114.     connected between a lead of cystal and ground
  115. 30pf cap2:
  116.     connected between other lead of crystal and ground
  117. 10uF Electrolytic Cap:
  118.     minus end to 8051 pin9, + end to +5 volts.
  119. 10k resistor:
  120.     tied between ground and 8051 pin 9
  121. VVV reset pushbutton switch. This is not absolutely necessary.
  122. Pushbutton Switch1:
  123.     tied between 8051 pin9 and +5 volts
  124. VVV only use if you want a one-button hard reset.
  125. Pushbutton Switch2: (amiga reset switch)
  126.     tied between 8051 pin12 (int0) and ground
  127. 5-pin Female IBM connector:
  128.     Connect plus voltage pin to +5 volts
  129.     Connect ground pin to ground
  130.     connect clock and data as in above
  131. (pin1=clock, pin2=data, pin3=NC, pin4=ground, pin5=+5v)
  132. (as you face the back of the 5-pin female din, with the notch pointing up,
  133. the pin order from left to right is 1,4,2,5,3)
  134.  
  135. Amiga Connector: each of the amiga connectors for the 500/1000/2000 will 
  136.     be different.
  137. On the Amiga 1000, the keyboard connects by means of a telephone
  138.     HANDSET connector with a regular phone handset cord. The pins
  139.     from left to right on the back of the Amiga 1000 are +5,clock,data,GND.
  140.     If you make this circuit yourself, I suggest purchasing a little jack
  141.     from the local telephone repairman. They are fairly standard jacks
  142.     I believe. Connect red on the jack to +5,white to clock,greeen to
  143.     data, black to ground. (On the circuit board, that is...)
  144.     Clock and Data are wherever you locate them in the source code.
  145.     As it stands, Amiga Clock is on pin 3 of the 8051, and Data is
  146.     on pin 4.
  147.  
  148. For the Amiga 500, there is a 8 pin straight line on the mother board.
  149. These pins from left to right are
  150. 1. Data
  151. 2. Clock
  152. 3. Reset
  153. 4.+5
  154. 5 Not connected. (Key)
  155. 6.Ground
  156. 7. Status (not used)
  157. 8. Disk Light (not used)
  158.  
  159. Make yourself a special adaptor that connects your amiga to the circuit.
  160. You WILL need to connect the reset line if you want to soft reset from
  161. the keyboard. The A500 only resets by having the Reset line driven low.
  162.  
  163. It says in my hardware manual here that The connector TO the keyboard
  164. goes as follows:
  165. 1: Clock
  166. 2: Data
  167. 3: Not connected.
  168. 4: Ground
  169. 5: +5 volts.
  170. I imagine it's just like the AT connector, but it's a shame they don't use
  171. the same data signals!
  172.  
  173.  
  174.  
  175. VERY IMPORTANT:!!!! The cord from the Amiga to the Converter must be
  176. very very short and have very low resistance for this circuit to run on it's
  177. own power. Do NOT use a long handset cord, it will load down the power lines.
  178. IT's made of ribbon copper wound around some white stuff and it conducts poorly
  179. on purpose. I used a hackup phone handset cord that is only about 3 inches
  180. long. That works fine. You may need to get a phone repairman to make the
  181. little cord special. He can do it, I know. It's a common thing. It shouldn't
  182. be expensive. The one he made for me cost 1$.
  183.  
  184. That's it!
  185. ====================================================================
  186. A little background on the IBM AT keyboard:
  187. The keyboard I used for this circuit was a BTC 5339sx. It costs about $40
  188. Lucky Computers, 1-800-348-5825. I have also tested the circuit on a 
  189. standard PC keyboard, and an HP Vectra AT keyboard.
  190.  
  191. The AT keyboard DIN connector has 5 pins. Pin 3 is called Reset, but it's
  192. reserved, so we can't use it. Forget it exists on the AT keyboard. They just
  193. charge you money for it. (joke) Open collectors drive the clock and data pins,
  194. so when they are not driven low, they float at 5 volts.
  195.  
  196. The keyboard transmits data by bits, each synchonous somehow with the clock
  197. line. They keyboard when clocking in or out data, always runs the clock.
  198. The controller can drive the clock line, but not with reference to data.
  199.     When the Keyboard sends data, it first sets the data, then drives
  200. clock low, then high, and then changes the data to the next value.
  201.     The AT uses 11 bits for a transmission, 1 start bit (0), 8 data
  202. bits, 1 parity bit-set if the number of 1's in the data bits is even, and
  203. a stop bit (1). When the keyboard sends it's last bit, the stop bit, the
  204. controller must drive clock line low as a handshake and to tell the 
  205. keyboard not to send until clock goes high again.
  206.     Theoretically, the controller could interrupt the sending of the
  207. bits, but I consider this unnecessary, and don't bother with it.
  208. When the computer needs to send a command to the keyboard, it sets clock
  209. line high and the data line low. When the keyboard sees this, it will
  210. start clocking pulsed on the data line. 
  211. Then, the controller must look for the clock line going low, set the data
  212. bit, wait for the clock to go high, then wait for the clock to go low
  213. again, and then change the bit. Thus, it changes the data in the middle
  214. of the clock low pulse. When the keyboard has received it's 10th bit,
  215. it will drive the data line low while at the same time clocking out
  216. an extra clock low pulse. Then, it expects a handshake of the clock line
  217. low from the controller.
  218.                     0       1       2   |   7       P     stop    extra
  219. Clock:------------\___/---\___/---\___/---\___/---\___/---\___/---\___/end
  220.  
  221. Data:-------\_______00000001111111122222|6677777777PPPPPPPP1111xxxxxxxx_____
  222.  
  223. Notice there is NO start bit when the controller sends data to the Keyboard.
  224.  
  225. Special Commands the Keyboard can Send to the Controller:
  226. -----------------------------------------------------------
  227. 00     Keyboard buffer overflowed
  228. AA     Selftest passed
  229. FA    The command sent was received correctly
  230. FE    The command sent was received poorly. Please resend.
  231.  
  232. Special Commands the Controller can Send to the Keyboard:
  233. -----------------------------------------------------------
  234. ED    Set the LEDs according to next byte I send
  235.     bit 0=Scroll lock 1=on
  236.     bit 1=Num lock
  237.     bit 2=Caps lock
  238.     bits 3-7 must be 0
  239. F4    clear the key buffer and start scanning
  240. F6    restore default values
  241. FE    retransmit last character, please
  242. FF    Reset, you stupid keyboard!
  243.  
  244. Whew! That about raps it up for the AT keybard! Enough said, right?
  245.  
  246.  
  247. XT keyboards transmit much the same way except they only use 10 bits.
  248. Two start bits (both high) and 8 data bits, transmitted in order 0-1-2...-7
  249. The last bit is a make/break bit which is 1 to signify a break.
  250.  
  251. The XT can have no commands sent to it. The way to reset it is to drive
  252. the Clock line low for some longish period of time. The keyboard will not
  253. send data (it will hold off) if the data line is being held low by an
  254. external source (the controller)
  255.  
  256. AMIGA SIDE=========================================
  257.  
  258. Now I bet you are all wondering which keys are mapped to which keys.
  259. I am using the 101 AT keyboard.
  260.  
  261. AT            Amiga
  262. ==            =====
  263.  
  264. Left Ctrl        Left Amiga
  265. Right Ctrl        Right Amiga
  266. F11            Numeric Keypad (
  267. F12            Numeric Keypad ) (doesn't work on A1000's)
  268. Capslock        Control (IF used in conjunction with another key)
  269. Delete            Delete
  270. Page Down        Help
  271. PrintScreen        Left Amiga
  272. ScrollLock        Right Amiga
  273. NumLock            Control
  274. (the above three keys mapped for easy one-hand reset)
  275. Insert            Amiga+Left Cursor
  276. Home            Amiga+Up Cursor
  277. End            Amiga+Down Cursor
  278. PageUp            Amiga+Right Cursor
  279. (the above keys mapped for easy mouse pointer control in workbench.)
  280.  
  281. The BTC keyboard I used also included a Macro key (conveniently) that
  282. is mapped as a control key.
  283.  
  284.  
  285. All other keys are mapped exactly the same.
  286.  
  287. Since the Control Keys on the AT are mapped to the Amiga keys,
  288. I made a little routine that defines the Capslock Key to work as
  289. Control if you hold it down first, then type the other key.
  290. Just use it as you would an ordinary Control key.
  291. This only works for the AT, not the XT since I can't control the lights
  292. on the XT.
  293.  
  294. The explanation for how the Amiga Keyboard works is provided in the
  295. Hardware Reference Manual. I will not repeat this info here, for fear of
  296. copyright infringements and because the manual is cheap and a valuable
  297. must for anyone who indulges in this kind of thing.
  298.  
  299.  
  300. <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  301.  
  302. SOFTWARE:
  303.  
  304. I have included the source and the machine code for the software that
  305. runs this circuit. The timing loops are pretty stringent so if you want to
  306. change things, better have a logic analyzer on hand!
  307.  
  308. I am also going to include a simple 8051 code assembler for those who don't
  309. like to hand-code. If you keep your programs neatly written, it should 
  310. assemble fine.
  311.  
  312. Documentation is within the program listing. It's not too hard to follow if
  313. you know what you are doing.
  314.  
  315. Feel free to change anything you want, but before you redistribute it,
  316. please tell me of the changes. Make it known within the program that you
  317. have made changes.
  318.  
  319. The circuit, once built, should never have to be removed once plugged into
  320. your computer. It should Auto Detect which style keyboard is hooked up
  321. if the XT/AT pin (now coded as Port 1.7 (pin 8)) is not tied low.
  322. IF for some reason the circuit does not start up fine, you may need
  323. a reset CIRCUIT switch. This is different than the reset Computer
  324. switch. This switch SHOULD restart the circuit and make it sync
  325. up to the computer and the keyboard.
  326.  
  327. I will sell anybody any number of the parts needed, from circuit board
  328. to telephone connectors to the whole thing.
  329.  
  330. Circuit board alone: 5$
  331. Telephone connector: 1.50$
  332. Whole thing minus case:25$ plus shipping.
  333. Full documentation: 1$ plus postage.
  334.  
  335. Any questions? Be glad to answer em!
  336. Email address: rudolpe@jacobs.cs.orst.edu
  337. Phone # 503-745-7466 (Oregon)
  338.  
  339.